#ifndef LOGINDIALOG_H
#define LOGINDIALOG_H

#include "register.h"
#include <QDialog>
#include <QPainter>

namespace Ui {
class LoginDialog;
}

class LoginDialog : public QDialog
{
    Q_OBJECT

public:
    static QString NICKNAME;
    static void init(QString name);
    explicit LoginDialog(QWidget *parent = 0);
    ~LoginDialog();

protected:
    void changeEvent(QEvent *e);

private slots:
    void on_login_clicked();

    void on_cancel_clicked();

    void on_pushButton_toggled(bool checked);

    void getUserInfo(QString name);

private:
    Ui::LoginDialog *ui;
    QSqlDatabase database;
    bool tableFlag;

    int usr_id;
    QString usr_passwd;
    QString usr_name;
    QString usr_email;
    int usr_history;
    bool matchFlag; 

    // 设置参数
    QString select_table = "select tbl_name name from sqlite_master where type = 'table'";
    QString create_sql = "create table user (chatid int primary key, passwd varchar(30), name varchar(30), email varchar(30), history int)";
    QString select_max_sql = "select max(chatid) from user";
    QString insert_sql = "insert into user values (?, ?, ?, ? ?)";
    //QString update_sql = "update user set name = :name where chatid = :chatid";
    QString select_sql = "select name from user";
    //QString select_all_sql = "select * from user";
    //QString delete_sql = "delete from user where chatid = ?";
    //QString clear_sql = "delete from user";

    QString select_nameInfo = "selcet * from user where name=";
};

#endif // LOGINDIALOG_H
